//
//  LineView.swift
//  SBNewProject
//
//  Created by hlt on 2023/9/11.
//

import UIKit


struct LineView{
    
    init(startPoint: CGPoint, widht: CGFloat) {
        let path = UIBezierPath()
        path.move(to: CGPoint(x: startPoint.x, y: startPoint.y))
        path.addLine(to: CGPoint(x: startPoint.x + widht, y: startPoint.y))
        path.close()
        let shaplayer = CAShapeLayer()
        shaplayer.strokeColor = self.color.cgColor
        shaplayer.fillColor = UIColor.clear.cgColor
        shaplayer.lineWidth = self.height
        shaplayer.path = path.cgPath
        self.shapeLayer = shaplayer
    }
    
    
    var color:UIColor =  R.color.lineColor {
        didSet{
            self.shapeLayer.strokeColor = self.color.cgColor
        }
    }
    
    var height:CGFloat = 0.5
    
    var shapeLayer:CAShapeLayer!
    
    func drawLineViewTo(view:UIView){
        view.layer.addSublayer(self.shapeLayer)
    }
    
}
